import type { MockMethod } from 'vite-plugin-mock'

import { mockDateUnix, resultPageSuccess } from './_util'

const domainItem = () => ({
  id: '@id',
  domain: '@domain',
  group_name: '@name',
  count: '@integer(0, 100)',
  created_at: mockDateUnix(),
  updated_at: mockDateUnix(),
  dns: '@domain',
  ns_status: '@integer(1, 2)',
  remark: '@name'
})

const dataSource = Array.from({ length: 297 }, () => domainItem())

export default [
  {
    method: 'get',
    url: '/mock/v1/domain',
    statusCode: 200,
    response: (query: { offset?: number; limit?: number }) =>
      resultPageSuccess(
        Number(query?.offset ?? 0),
        Number(query?.limit ?? 20),
        dataSource
      )
  }
] as MockMethod[]
